<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>数组洗牌</title>
</head>
<body>
<script>
    // 利用内置的Math.random()方法。
    const list = [1, 2, 3, 4, 5, 6, 7, 8, 9];
    list.sort(() => {
        return Math.random() - 0.5;
    });
    console.log('%c   list: ', 'color: MidnightBlue; background: Aquamarine; font-size: 20px;', list);

    // 输出
    // (9) [2, 5, 1, 6, 9, 8, 4, 3, 7]
    // 输出
    // (9) [4, 1, 7, 5, 3, 8, 2, 9, 6]

</script>
</body>
</html>